package com.ruoyi.quality.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.quality.domain.BzInfo;
import com.ruoyi.quality.service.IBzInfoService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 标准信息Controller
 * 
 * @author lgq
 * @date 2023-03-16
 */
@RestController
@RequestMapping("/quality/bz")
@Api(value="标准信息",tags = "标准信息")
public class BzInfoController extends BaseController
{
    @Autowired
    private IBzInfoService bzInfoService;

    /**
     * 查询标准信息列表
     */
    @GetMapping("/list")
    @ApiOperation(value="查询标准信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "页数", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true, dataType = "String"),
    })
    public TableDataInfo list(BzInfo bzInfo)
    {
        startPage();
        List<BzInfo> list = bzInfoService.selectBzInfoList(bzInfo);
        return getDataTable(list);
    }

    /**
     * 导出标准信息列表
     */
    @Log(title = "标准信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BzInfo bzInfo)
    {
        List<BzInfo> list = bzInfoService.selectBzInfoList(bzInfo);
        ExcelUtil<BzInfo> util = new ExcelUtil<BzInfo>(BzInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取标准信息详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value="获取标准信息详细信息")
    @ApiImplicitParam(paramType="query", name = "id", value = "主键", required = true, dataType = "String")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bzInfoService.selectBzInfoById(id));
    }

    /**
     * 新增标准信息
     */
    @Log(title = "标准信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="新增标准信息")
    public AjaxResult add(@ApiParam(name="标准信息",value="传入json格式",required=true)@RequestBody BzInfo bzInfo)
    {
        return toAjax(bzInfoService.insertBzInfo(bzInfo));
    }

    /**
     * 修改标准信息
     */
    @Log(title = "标准信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改标准信息")
    public AjaxResult edit(@ApiParam(name="标准信息",value="传入json格式",required=true)@RequestBody BzInfo bzInfo)
    {
        return toAjax(bzInfoService.updateBzInfo(bzInfo));
    }

    /**
     * 删除标准信息
     */
    @Log(title = "标准信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="删除标准信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bzInfoService.deleteBzInfoByIds(ids));
    }
}
